package com.example.demo.aop;

public class LockManager {

    private static ThreadLocal<LockManager> INSTANCE_HOLDER = new ThreadLocal<>();

    private String lock;


    public static LockManager getInstance() {
        LockManager result = new LockManager();
        INSTANCE_HOLDER.set(result);
        return result;
    }

    public void setLock(String lock) {
        this.lock = lock;
    }

    public static String getLock() {
        return INSTANCE_HOLDER.get() != null ? INSTANCE_HOLDER.get().lock : "";
    }

    public static void clear() {
        INSTANCE_HOLDER.remove();
    }
}
